# include<iostream>
# include<vector>
# include"NewtonFormula.h"
# include"Function.h"
# include"NewtonSolver.h"

using namespace::std;

# define N 5

int main()
{
    double Time[N] = {0, 3, 5, 8, 13};
    double Distance[N] = {0, 225, 383, 623, 993};
    double Speed[N] = {75, 77, 80, 74, 72};

    NewtonFormula Solver(N, Time, Distance, Speed);

    // Topic (a)
    cout << "At t = 10s, position is " << Solver.sovle(10) << endl;
    Polynomial p1(Solver.GetPoly());
    p1.PrintCoff();
    cout << "The speed is " << Solver.diff(10) << endl;
    Polynomial p2(Solver.GetDiff());
    p2.PrintCoff();

    // Topic (b)
    Polynomial f(Solver.GetDiff());
    f = f - 81;
    NewtonSolver N1(5, 0.000001, 15, f);
    double t = N1.solve();
    cout << "Root is " << t << endl;
    cout << "Derivation is " << Solver.diff(t) << "feet per second." << endl;
    cout << "Finish testing." << endl;

    return 0;
}